25 August 2018

knitr::opts_chunk$set(echo = TRUE)
library(plotly)
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.4.4
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

Assignment set up

  • Load library plotly
  • load cars data set
  • create a plot

Slide with R Output

plot_ly(cars, x = ~speed, y = ~dist, type = "scatter", color = ~dist)
## No scatter mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plot.ly/r/reference/#scatter-mode
## Warning: package 'bindrcpp' was built under R version 3.4.4